#ifndef __BSP_ADS8320_H
#define __BSP_ADS8320_H
#include "LPC17xx.h"
#include "lpc17xx_gpio.h"
#include "lpc17xx_pinsel.h"

#define ADS8320_CS1(x)	((x) ? GPIO_SetValue(0,1<<20):GPIO_ClearValue(0,1<<20));
#define ADS8320_CS2(x)	((x) ? GPIO_SetValue(0,1<<21):GPIO_ClearValue(0,1<<21));
#define ADS8320_CLK(x)	((x) ? GPIO_SetValue(0,1<<19):GPIO_ClearValue(0,1<<19));
#define SCK_HIGH  LPC_GPIO0->FIOSET |= (1<<15)
#define SCK_LOW	  LPC_GPIO0->FIOCLR |= (1<<15)
#define DOUT_HIGH LPC_GPIO0->FIOSET |= (1<<18)
#define DOUT_LOW  LPC_GPIO0->FIOCLR |= (1<<18)
#define DIN_HIGH  LPC_GPIO0->FIOSET |= (1<<17)
#define DIN_LOW   LPC_GPIO0->FIOCLR |= (1<<17)
#define DIN ((LPC_GPIO0->FIOPIN & (1<<17)) ? 1 : 0)
#define ADCS_HIGH   LPC_GPIO0->FIOSET |= (1<<6)
#define ADCS_LOW    LPC_GPIO0->FIOCLR |= (1<<6)
#define DACS_HIGH   LPC_GPIO0->FIOSET |= (1<<7)
#define DACS_LOW    LPC_GPIO0->FIOCLR |= (1<<7)
void bsp_ads8320_init(void);
void delay(uint32_t ticks);
uint32_t read_ads8320_v(void);
uint32_t read_ads8320_i(void);
#endif
